home *** CD-ROM | disk | FTP | other *** search
- Path: lovage.lerc.nasa.gov!edfollo
- From: edfollo@lovage.lerc.nasa.gov (Jeff Follo)
- Newsgroups: comp.lang.c++
- Subject: Help -- Problem with Protected Class in Borland 4.5
- Date: 29 Feb 1996 15:08:13 GMT
- Organization: NASA Lewis Research Center
- Distribution: world
- Message-ID: <4h4fgt$ina@sulawesi.lerc.nasa.gov>
- NNTP-Posting-Host: lovage.lerc.nasa.gov
-
-
- I'm using Borland C++ 4.5, trying to create either a DOS target or a EasyWin
- target. I cannot get the following code to compile:
-
- #include <iostream.h>
-
- class BaseClass
- {
- public:
- int a;
- protected:
- int b;
- };
-
-
- class UpperClass : public BaseClass
- {
- public:
- void print_a() {cout << "\na = " << a;}
- void print_b() {cout << "\nb = " << b;}
- };
-
- void main()
- {
- UpperClass x;
-
- x.a = 1;
- x.b = 2;
-
- x.print_a();
- x.print_b();
-
- }
-
-
- The error I get is:
-
- 'BaseClass::b' is not accessible in function main()
-
-
- The code works if I comment out protected. What's wrong here?
-
-